﻿using BST250301TestStand.Models;
using NPOI.Util;
using OpenTK.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace BST250301TestStand.Models.Helpers
{
    internal class Copy
    {
        // JSON序列化（现代推荐方式）
        public static T DeepCopyJson<T>(T obj)
        {
            if (ReferenceEquals(obj, null))
                return default;

            var json = JsonSerializer.Serialize(obj);
            return JsonSerializer.Deserialize<T>(json);
        }
        public static ProjectItem ProjectItemCopyJson(ProjectItem obj)
        {
            var item = new ProjectItem();
            item.CFStatus = obj.CFStatus;
            item.CRStatus = obj.CRStatus;
            item.CPTOStatus = obj.CPTOStatus;
            item.TemperatureOil = obj.TemperatureOil;
            item.SlaveGearPosition = obj.SlaveGearPosition;
            item.MasterGearPosition = obj.MasterGearPosition;
            item.ConfirmWay = obj.ConfirmWay;
            item.Name = obj.Name;
            item.Description = obj.Description;
            item.OrderID = obj.OrderID;
            item.RotateSpeed = obj.RotateSpeed;
            item.CRSetPointCurrent = obj.CRSetPointCurrent;
            item.CFSetPointCurrent = obj.CFSetPointCurrent;
            item.CPTOSetPointCurrent = obj.CPTOSetPointCurrent;
            return item;
        }

    }
}
